﻿<%@ Page Language="C#" MasterPageFile="~/Template.master" AutoEventWireup="true"
    CodeFile="InternalAccounting.aspx.cs" Inherits="InternalAccountingPage" Title="Ghasam | Internal Accounting List" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager ID="smInternalAccounting" runat="server" ScriptMode="Release">
    </asp:ScriptManager>

    <div>
        <h3>
            لیست هزینه های داخلی</h3>
    </div>
    <div>
        <hr />
    </div>
    <br />
    <div>
        شماره فاکتور:
        <asp:TextBox ID="txtInvoiceNumber" ValidationGroup="SearchValidation" runat="server" />
        <asp:RegularExpressionValidator ID="revInvoiceNumber" Display="Dynamic" ValidationGroup="SearchValidation" ValidationExpression="\d+" ErrorMessage="لطفا یک عدد را برای شماره فاکتور وارد کنید" ControlToValidate="txtInvoiceNumber" runat="server" />
        &nbsp;&nbsp;&nbsp;&nbsp; حساب :
        <asp:DropDownList ID="ddlAccounts" AppendDataBoundItems="true" runat="server">
            <asp:ListItem Text="---" Value="-1" />
        </asp:DropDownList>
        &nbsp;&nbsp;&nbsp;&nbsp; فروشنده :
        <ajax:AutoCompleteExtender ID="aceSalesPersonName" TargetControlID="txtSalesPerson" ServicePath="~/WebService/AutoCompleteService.asmx"
                    ServiceMethod="GetSalesPersonName" MinimumPrefixLength="2" CompletionInterval="1000"
                    EnableCaching="true" CompletionSetCount="12" runat="server" />
                <asp:TextBox ID="txtSalesPerson" autocomplete="off" runat="server" />
        <br />
        <br />
        تاریخ ثبت هزینه از :
        <asp:TextBox ID="txtStartDate" runat="server" />
        <mani:PersianDateValidator ID="pdvStartDate" Display="Dynamic" ControlToValidate="txtStartDate" ValidationGroup="SearchValidation" runat="server" />
        &nbsp;&nbsp;&nbsp;&nbsp; تا :
        <asp:TextBox ID="txtEndDate" runat="server" />
        <mani:PersianDateValidator ID="pdvEndDate" Display="Dynamic" ControlToValidate="txtEndDate" ValidationGroup="SearchValidation" runat="server" />
        &nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Label ID="lblAccountingType" runat="server" Text="نوع هزینه :" />
        <asp:DropDownList ID="drpAccountingType" runat="server">
            <asp:ListItem Text="همه" Value="-1" />
            <asp:ListItem Text="رسمی" Value="1" Selected="True" />
            <asp:ListItem Text="غیر رسمی" Value="2" />
            <asp:ListItem Text="اعلامی" Value="3" />
        </asp:DropDownList>
    </div>
    <br />
    <div>
        <asp:Button ID="btnSearch" ValidationGroup="SearchValidation" Text="جستجو" runat="server" OnClick="btnSearch_Click" />
    </div>
    <div>
        <hr />
    </div>
    <div>
        <mani:PagingGridView ID="gvInternalAccountings" VirtualItemCount="-1" runat="server"
            AutoGenerateColumns="False" PageSize="15" AllowPaging="true" DataKeyNames="Id"
            OnPageIndexChanging="gvInternalAccountings_PageIndexChanging" OnRowDeleting="gvInternalAccountings_RowDeleting"
            OnSelectedIndexChanged="gvInternalAccountings_SelectedIndexChanged" 
            onsorting="gvInternalAccountings_Sorting">
            <Columns>
                <asp:BoundField DataField="Id" HeaderText="Id" Visible="false" InsertVisible="False"
                    ReadOnly="True" SortExpression="Id" />
                <asp:TemplateField HeaderText="نوع" SortExpression="AccountingType.Description">
                    <ItemTemplate>
                        <%# Eval("AccountingType.Description")%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="AccountName" HeaderText="حساب" SortExpression="account.Name" />
                <asp:BoundField DataField="SalesPersonName" HeaderText="فروشنده" SortExpression="salesPerson.Title"/>
                <asp:BoundField DataField="ItemName" HeaderText="کالا" />
                <asp:TemplateField HeaderText="مقدار">
                    <ItemTemplate>
                        <%# Eval("Quantity") + " " + Eval("ItemUnit").ToString() %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="تخفیف">
                    <ItemTemplate>
                        <%# Mani.Common.UIHelper.FormatString(Eval("Credit"))%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="برداشت" SortExpression="Debit">
                    <ItemTemplate>
                        <%# Mani.Common.UIHelper.FormatString(Eval("Debit"))%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="InvoiceNumber" HeaderText="فاکتور" SortExpression="InvoiceNumber"/>
                <asp:BoundField DataField="Description" HeaderText="توضیحات" />
                <asp:TemplateField HeaderText="تاریخ ثبت" SortExpression="AccountingDate">
                    <ItemTemplate>
                        <%# Mani.Common.MyPersianDate.DateTimeToPersian(Eval("AccountingDate"))%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="تاریخ آخرین ویرایش " SortExpression="ModifyStamp">
                    <ItemTemplate>
                        <%# Mani.Common.MyPersianDate.DateTimeToPersian(Eval("ModifyStamp"))%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="EditInternalAccounts" runat="server" CausesValidation="False"
                            CommandName="Select">
                                <img src="App_Themes/<%=Page.Theme %>/images/edit.gif" alt="" style="border:0;" />
                        </asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="DeleteAccounting" runat="server" CausesValidation="False" CommandName="Delete">
                                <img src="App_Themes/<%=Page.Theme %>/images/delete.gif" alt="" style="border:0;" />
                        </asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </mani:PagingGridView>
        <hr />
        <table id="tbEdit" visible="false" runat="server">
            <tr>
                <td>
                    تاریخ هزینه :
                </td>
                <td>
                    <asp:TextBox ID="txtAccountingDate" ValidationGroup="EditValidation" runat="server" />
                    <mani:PersianDateValidator ID="pdvAccountingDate" Display="Dynamic" ControlToValidate="txtAccountingDate" ValidationGroup="EditValidation" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    حساب :
                </td>
                <td>
                    <asp:DropDownList ID="ddlAccount" AppendDataBoundItems="true" runat="server">
                        <asp:ListItem Text="---" Value="-1" />
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    نام فروشنده :
                </td>
                <td>
                    <ajax:AutoCompleteExtender ID="ace2" TargetControlID="txtSalesPersonEdit" ServicePath="~/WebService/AutoCompleteService.asmx"
                    ServiceMethod="GetSalesPersonName" MinimumPrefixLength="2" CompletionInterval="1000"
                    EnableCaching="true" CompletionSetCount="12" runat="server" />
                    <asp:TextBox ID="txtSalesPersonEdit" autocomplete="off" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    نام کالا :
                </td>
                <td>
                    <ajax:AutoCompleteExtender ID="ace3" TargetControlID="txtItemName" ServicePath="~/WebService/AutoCompleteService.asmx"
                    ServiceMethod="GetItemName" MinimumPrefixLength="2" CompletionInterval="1000"
                    EnableCaching="true" CompletionSetCount="12" runat="server" />
                    <asp:TextBox ID="txtItemName" autocomplete="off" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    مقدار :
                </td>
                <td>
                    <asp:TextBox ID="txtQuantity" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    قیمت واحد :
                </td>
                <td>
                    <asp:TextBox ID="txtUnitPrice" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    تخفیف :
                </td>
                <td>
                    <asp:TextBox ID="txtDiscount" runat="server" /> ریال
                </td>   
            </tr>
            <tr>
                <td>
                    شماره فاکتور :
                </td>
                <td>
                    <asp:TextBox ID="txtInvoiceNo" runat="server" />
                </td>
            </tr>
            <tr>
                <td> 
                    نقدی :
                </td>
                <td>
                    <asp:CheckBox ID="cbPaid" runat="server" />
                </td>
            </tr>
            <tr id="trInternalAccountingType" visible="false" runat="server">
                <td> 
                    نوع هزینه :
                </td>
                <td>
                    <asp:DropDownList ID="ddlInternalAccountingType" runat="server">
                        <asp:ListItem Text="رسمی" Value="1" />
                        <asp:ListItem Text="غیر رسمی" Value="2" />
                        <asp:ListItem Text="اعلامی" Value="3" />
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    توضیحات :
                </td>
                <td>
                    <asp:TextBox ID="txtDesc" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button Id="btnUpdateInternalAccounting" CausesValidation="true" ValidationGroup="EditValidation" Text="ذخیره" runat="server" 
                        onclick="btnUpdateInternalAccounting_Click" />
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
